package com.xpec.c4.codec.h2o;

public class WireFormat {

	private WireFormat() {
	}

//	/**
//	 * 可变长度整型。 boolean,byte,char,short,int,long
//	 */
//	public static final int WIRETYPE_VARINT = 0;
//	/**
//	 * 字符串, 数组，集合，自定义类
//	 */
//	public static final int WIRETYPE_LENGTH_DELIMITED = 1;
//	/**
//	 * 浮点4字节 float
//	 */
//	public static final int WIRETYPE_FIXED32 = 2;
//	/**
//	 * 浮点8字节 double
//	 */
//	public static final int WIRETYPE_FIXED64 = 3;
	
	/**
	 * 所占位数
	 */
	private static final int TAG_TYPE_BITS = CodedInfo.TYPE_BITS;

	private static final int TAG_TYPE_MASK = (1 << TAG_TYPE_BITS) - 1;

	protected static int getTagWireType(int tag) {
		return tag & TAG_TYPE_MASK;
	}

	protected static int getTagFieldNumber(int tag) {
		return tag >>> TAG_TYPE_BITS;
	}

	protected static int makeTag(int fieldNumber, int wireType) {
		return (fieldNumber << TAG_TYPE_BITS) | wireType;
	}

	public static void main(String[] args) {
		System.out.println(makeTag(3, 1));
		System.out.println(getTagFieldNumber(9));
	}
}
